package com.brooks.demo;

import java.util.concurrent.TimeUnit;

/**
 * run 和 start 区别
 * @Author mihutu
 * @Date 2020/10/16 09:50
 * @Version 1.0
 */
public class DemoThread2 {
   private static class T1 extends Thread{
       @Override
       public void run() {
           for (int i=0;i<10;i++){
               try {
                   TimeUnit.SECONDS.sleep(1);
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }
               System.out.println("T1");
           }
       }

       public static void main(String[] args) {
           //run方法会执行完T1后再执行后面的
//           new T1().run();
           //start方法会开一个支线程和主线程一起执行
           new T1().start();
           for (int j=0;j<10;j++){
               try {
                   TimeUnit.SECONDS.sleep(1);
               } catch (InterruptedException e) {
                   e.printStackTrace();
               }
               System.out.println("main");
           }
       }
   }
}
